//app.js
var nami = require('/nami/index.js');
App({
  onLaunch: function () {
    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)

    var app = this;
    nami.login(() => {
      nami.getUserInfo((userInfo) => {
        console.log("已获取用户信息数据:", userInfo);
        app.globalData.userInfo = userInfo;
        wx.setStorageSync('userInfo', userInfo);
      }, () => {
        console.log("用户拒绝提供信息:");
      });
      nami.getAllInfo((openId) => {
        console.log("已获取id", openId);
        app.globalData.openId = openId;
        wx.setStorageSync('openId', openId);
      }, () => {
        console.log("获取id失败");
      })
    });
  },
  globalData: {
    userInfo: null,
    openId: null
  }
})